Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: How to know when a player is walking/running?

  1. #11

    Default

    yes its because

    local.player is not a player...its nothing = nil , zip, empty, gone, a variable of nothingness.

    you need to make local.player..something./

    1. So what is your player variable?
    2. is this single or multiplayer?
    3. post the rest of your code , or a portion that is to check his movement.
    4. send me gold , your daughters and a bike pump

  2. #12
    Client Beta Testers Appelpitje's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    545

    Default

    Quote Originally Posted by Elgan View Post
    1. So what is your player variable?
    The player himself?

    Quote Originally Posted by Elgan View Post
    2. is this single or multiplayer?
    Multiplayer

    Quote Originally Posted by Elgan View Post
    3. post the rest of your code , or a portion that is to check his movement.
    It's the only thing i currently have and a dmprecache that execute it.

    Quote Originally Posted by Elgan View Post
    4. send me gold , your daughters and a bike pump
    I dont have gold nor daughters, but i have a bike pump

  3. #13

    Default

    ok.

    1.. the player it is not.

    2. good

    3.. If youre executing this as it is..it wont be anything, hence do nothing.
    ..what are you trying to make?

    4. Ok cool, will you cover postage? or drop it off in Suffolk,uK? I would prefer a drop off...and wife?

  4. #14
    Client Beta Testers Appelpitje's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    545

    Default

    Yeah sorry i readed nr 1 in a hurry im just tryng to detect every player when hes walking or not and disable lean when the player is not walking.
    So its basically the other way like dmflag NO_LEAN works.

  5. #15

    Default

    ohhhhhhhhhhhhhhhhh...

    best way is to use state files probably, but first....did anyone make a mod like this? it must of been done before?

  6. #16
    Client Beta Testers Appelpitje's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    545

    Default

    I know how to open the state file and read things in it. But what do you mean by using it?
    I have used it for weaponswapping and recoilchecking but idk what u mean with using the state file for getting the movement from a player.

    Have found a little script here: http://www.modtheater.com/threads/ra...6/#post-316904

    Will try to make something...

    EDIT: Im still getting the error:
    Code:
    local.position = local.player getposition  (global/nolean.scr, 4)
    local.position = local.player ^
    
    ^~^~^ Script Error: command 'getposition' applied to NULL listener
    
    local.movement = local.player getmovement (global/nolean.scr, 5)
    local.movement = local.player ^
    
    ^~^~^ Script Error: command 'getmovement' applied to NULL listener
    How can i fix that? I just want to detect when a player is walking/crouching..

    Code im using:
    Code:
    while(1)
    {
    local.position = local.player getposition 
    local.movement = local.player getmovement
    
    if(local.position == crouching)
    {
    println "im crouching"
    $player stufftext "+leanleft; +leanright"
    wait 0.3
    }
    
    else
    waitframe
    }
    Last edited by Appelpitje; May 15th, 2013 at 10:19 AM.

  7. #17
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    The variable 'local.player' was never assigned an entity or anything, so it is NIL by default.

    In a multiplayer context $player is not an entity, rather $player is an array of entities.
    It will, however, stay NULL, as long as no players have entered the game.
    If all players leave the round/level, it'll still be an array, but it'll have a size of 0.

    So it should look more like:
    Code:
    main:
          while !($player) 
                 wait 1
          
          while(1) {
               for (local.i = 1; local.i <= $player.size; local.i++) {
                    if ($player[local.i].nolean == NIL) {
                        thread nolean $player[local.i]
                    }
               }
          }
    end
    
    nolean local.player:
          local.player.nolean = 1
          while (local.player) {
                local.position = local.player getposition
                if (local.position == "crouching") {
                     println "im crouching"
                     local.player stufftext "+leanleft;+leanright"
                     wait 0.3
                }
                else {
                     waitframe
                }
           }
    end
    I'm not sure what you're trying to do, though. At the moment, anyone who crouches even once will have their leaning disabled.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  8. #18
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,245

    Default

    You can use .runheld command from Reborn. I don't rmember if it's available in 1.116 or if you need to wait for 1.117

  9. #19
    Client Beta Testers Appelpitje's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    545

    Default

    Quote Originally Posted by Sor View Post
    The variable 'local.player' was never assigned an entity or anything, so it is NIL by default.

    In a multiplayer context $player is not an entity, rather $player is an array of entities.
    It will, however, stay NULL, as long as no players have entered the game.
    If all players leave the round/level, it'll still be an array, but it'll have a size of 0.

    So it should look more like:
    Code:
    main:
          while !($player) 
                 wait 1
          
          while(1) {
               for (local.i = 1; local.i <= $player.size; local.i++) {
                    if ($player[local.i].nolean == NIL) {
                        thread nolean $player[local.i]
                    }
               }
          }
    end
    
    nolean local.player:
          local.player.nolean = 1
          while (local.player) {
                local.position = local.player getposition
                if (local.position == "crouching") {
                     println "im crouching"
                     local.player stufftext "+leanleft;+leanright"
                     wait 0.3
                }
                else {
                     waitframe
                }
           }
    end
    I'm not sure what you're trying to do, though. At the moment, anyone who crouches even once will have their leaning disabled.
    In spearhead when you crouch and stand still then u can lean even with the dmflag off. Im tryng to avoid this for clipping.
    Anyway thanks for the script, i tried it and gave me an overflow error when i entered the server:
    Code:
                    if ($player[local.i].nolean == NIL) { (global/nolean3.scr, 7)
                    if (^
    
    ********************
    ERROR: Command overflow.  Possible infinite loop in thread.
    
    ********************
    Quote Originally Posted by Razo[R]apiD View Post
    You can use .runheld command from Reborn. I don't rmember if it's available in 1.116 or if you need to wait for 1.117
    Im using spearhead, wish there is a reborn version for sh

  10. #20
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Ah yeah, forgot to put a wait in there, one second should do.

    You still have to reverse the changes when the player is not standing, or leaning will remain disabled.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •